package cn.heyige.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.heyige.backend.entity.DivinationSettingDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Optional;

/**
 * 用户占卜设置Mapper接口
 */
public interface SettingsMapper extends BaseMapper<DivinationSettingDO> {

    /**
     * 根据用户ID查询占卜设置
     *
     * @param userId 用户ID
     * @return 占卜设置
     */
    @Select("SELECT * FROM divination_setting WHERE user_id = #{userId}")
    Optional<DivinationSettingDO> findByUserId(@Param("userId") Integer userId);

    /**
     * 删除指定用户的占卜设置
     *
     * @param userId 用户ID
     */
    @Delete("DELETE FROM divination_setting WHERE user_id = #{userId}")
    void deleteByUserId(@Param("userId") Integer userId);
}